/**
 * 
 */
package com.wzl.qs;

import java.io.FileNotFoundException;
import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wzl.qs.db.ENote;

/**
 * @author g0800981
 * 
 */
public class FavoriteNoteAdapter extends BaseAdapter {

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getCount()
	 */
	private Context context;
	private ArrayList<ENote> noteList;
	private static final String LOGTAG = "FavoriteNoteAdapter--getView";
	private static final int IS_FAVORITE = 1;

	public FavoriteNoteAdapter(Context context, ArrayList<ENote> noteList) {
		this.context = context;
		this.noteList = noteList;
	}

	@Override
	public int getCount() {
		return noteList.size();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getItem(int)
	 */
	@Override
	public Object getItem(int position) {
		return noteList.get(position);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getItemId(int)
	 */
	@Override
	public long getItemId(int position) {
		return position;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getView(int, android.view.View,
	 * android.view.ViewGroup)
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ENote aNote = noteList.get(position);
		NoteAdapterView theView = null;
		try {
			theView = new NoteAdapterView(this.context, aNote, IS_FAVORITE);
		} catch (FileNotFoundException e) {
			Log.e(LOGTAG, e.getMessage());

		}
		return theView;
	}

}
